package com.ayic.garbagerecycle.pojo;


import lombok.Data;

@Data
public class Result {

    private Integer code; //状态响应码
    private String message; //状态描述
    private Object data; //数据

    public static Result success() {   //通用正确响应结果
        Result result = new Result();
        result.code = 1;
        result.message = "操作成功";
        return result;
    }

    public static Result success(String message) {   //带提示的正确响应结果
        Result result = new Result();
        result.code = 1;
        result.message = message;
        return result;
    }


    public static Result success(Object object, String message) {    //带提示和数据的正确响应结果
        Result result = new Result();
        result.data = object;
        result.code = 1;
        result.message = message;
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.message = msg;
        result.code = 0;
        return result;
    }

    public static Result success(PageResult<?> pageResult) {
        Result result = new Result();
        result.data = pageResult;
        result.code = 1;
        result.message = "操作成功";
        return result;
    }

    public static Result success(Object data) {    //只接收数据对象的正确响应结果
        Result result = new Result();
        result.data = data;
        result.code = 1;
        result.message = "操作成功";
        return result;
    }
}
